home *** CD-ROM | disk | FTP | other *** search
/ Complete Linux / Complete Linux.iso / docs / apps / database / postgres / postgre3.z / postgre3 / src / lib / H / access / transam.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-08-27  |  4.0 KB  |  140 lines

  1. /* ----------------------------------------------------------------
  2.  *   FILE
  3.  *    transam.h
  4.  *    
  5.  *   DESCRIPTION
  6.  *    postgres transaction access method support code header
  7.  *
  8.  *   NOTES
  9.  *    Transaction System Version 101 now support proper oid
  10.  *    generation and recording in the variable relation.
  11.  *
  12.  *   IDENTIFICATION
  13.  *    $Header: /private/postgres/src/lib/H/access/RCS/transam.h,v 1.6 1992/05/28 20:26:30 mer Exp $
  14.  * ----------------------------------------------------------------
  15.  */
  16.  
  17. #ifndef TransamIncluded       /* include this file only once */
  18. #define TransamIncluded 1
  19.  
  20. /* ----------------
  21.  *    transaction system version id
  22.  *
  23.  *    this is stored on the first page of the log, time and variable
  24.  *    relations on the first 4 bytes.  This is so that if we improve
  25.  *    the format of the transaction log after postgres version 2, then
  26.  *    people won't have to rebuild their databases.
  27.  *
  28.  *    TRANS_SYSTEM_VERSION 100 means major version 1 minor version 0.
  29.  *    Two databases with the same major version should be compatible,
  30.  *    even if their minor versions differ.
  31.  * ----------------
  32.  */
  33. #define TRANS_SYSTEM_VERSION    101
  34.  
  35. /* ----------------
  36.  *    transaction id status values
  37.  *
  38.  *    someday we will use "11" = 3 = XID_INVALID to mean the
  39.  *    starting of run-length encoded log data.
  40.  * ----------------
  41.  */
  42. #define XID_COMMIT      2               /* transaction commited */
  43. #define XID_ABORT       1               /* transaction aborted */
  44. #define XID_INPROGRESS  0               /* transaction in progress */
  45. #define XID_INVALID     3               /* other */
  46.  
  47. typedef unsigned char XidStatus;         /* (2 bits) */
  48.  
  49. /* ----------------
  50.  *       BitIndexOf computes the index of the Nth xid on a given block
  51.  * ----------------
  52.  */
  53. #define BitIndexOf(N)   ((N) * 2)
  54.  
  55. /* ----------------
  56.  *    transaction page definitions
  57.  * ----------------
  58.  */
  59. #define TP_DataSize        BLCKSZ
  60. #define TP_NumXidStatusPerBlock    (TP_DataSize * 4)
  61. #define TP_NumTimePerBlock    (TP_DataSize / 4)
  62.  
  63. /* ----------------
  64.  *    LogRelationContents structure
  65.  *
  66.  *    This structure describes the storage of the data in the
  67.  *    first 128 bytes of the log relation.  This storage is never
  68.  *    used for transaction status because transaction id's begin
  69.  *    their numbering at 512.
  70.  *
  71.  *    The first 4 bytes of this relation store the version
  72.  *    number of the transction system.
  73.  * ----------------
  74.  */
  75. typedef struct LogRelationContentsData {
  76.    int            TransSystemVersion;
  77. } LogRelationContentsData;
  78.  
  79. typedef LogRelationContentsData *LogRelationContents;
  80.  
  81. /* ----------------
  82.  *    TimeRelationContents structure
  83.  *
  84.  *    This structure describes the storage of the data in the
  85.  *    first 2048 bytes of the time relation.  This storage is never
  86.  *    used for transaction commit times because transaction id's begin
  87.  *    their numbering at 512.
  88.  *
  89.  *    The first 4 bytes of this relation store the version
  90.  *    number of the transction system.
  91.  * ----------------
  92.  */
  93. typedef struct TimeRelationContentsData {
  94.    int            TransSystemVersion;
  95. } TimeRelationContentsData;
  96.  
  97. typedef TimeRelationContentsData *TimeRelationContents;
  98.  
  99. /* ----------------
  100.  *    VariableRelationContents structure
  101.  *
  102.  *    The variable relation is a special "relation" which
  103.  *    is used to store various system "variables" persistantly.
  104.  *    Unlike other relations in the system, this relation
  105.  *    is updated in place whenever the variables change.
  106.  *
  107.  *    The first 4 bytes of this relation store the version
  108.  *    number of the transction system.
  109.  *
  110.  *    Currently, the relation has only one page and the next
  111.  *    available xid, the last committed xid and the next
  112.  *    available oid are stored there.
  113.  * ----------------
  114.  */
  115. typedef struct VariableRelationContentsData {
  116.    int            TransSystemVersion;
  117.    TransactionId    nextXidData;
  118.    TransactionId    lastXidData;
  119.    oid            nextOid;
  120. } VariableRelationContentsData;
  121.  
  122. typedef VariableRelationContentsData *VariableRelationContents;
  123.  
  124. /* ----------------
  125.  *    extern declarations
  126.  * ----------------
  127.  */
  128.   
  129. /* ----------------
  130.  *    global variable extern declarations
  131.  * ----------------
  132.  */
  133. extern Relation    LogRelation;
  134. extern Relation    TimeRelation;
  135. extern Relation    VariableRelation;
  136.  
  137. extern bool AMI_OVERRIDE;
  138.  
  139. #endif TramsamIncluded
  140.